<%@ Page Title="Show Case:User Login Sample (PostBack)" Language="C#" MasterPageFile="~/Demo.master" Inherits="DemoPage" %>

<%@ Register Src="~/CodeFormatter.ascx" TagName="Code" TagPrefix="demo" %>
<%@ Import Namespace="System.Security" %>

<script runat="server">
    protected void OnLoginCommand(object sender, CommandEventArgs e)
    {
        if (Membership.ValidateUser(txtUser.Text, txtPwd.Text))
        {
            if (cbAutoLogin.Checked)
                FormsAuthentication.SetAuthCookie(txtUser.Text, true);
        }
        else
            Dialog.ShowModalDialog(this, "Login Fail", "Login Fail ! User or password is not correct.", DialogIcons.Error);
    }

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="DemoHolder" runat="Server">
    <div class="dna-state-help  ui-corner-all">
        This example will use the ASP.NET Server Controls in Dialog and Handling Dialog's
        "ButtonCommand" to valid the user name and password.If user login fail it will show
        you using Dialog.ShowModleDialog to show the message dialog directly on server.</div>
    <br />
    <%--    <asp:HyperLink ID="LoingButton" runat="server" Style="cursor: pointer">Login</asp:HyperLink>--%>
    <DotNetAge:SimpleButton ID="LoingButton" runat="server" Text="Login" IconCssClass="ui-icon ui-icon-person" />
    <DotNetAge:Dialog ID="DemoDialog" runat="server" Draggable="true" Resizable="false"
        Title="User Login" ShowModal="true" OnButtonCommand="OnLoginCommand" Position="Top">
        <Trigger TargetID="LoingButton" />
        <Buttons>
            <DotNetAge:DialogButton Text="Login" CommandName="Login" CommandArgument="1" />
            <DotNetAge:DialogButton Text="Cancel" OnClientClick="$(this).dialog('close')" />
        </Buttons>
        <BodyTemplate>
            <div class="dna-demo-fields">
                <ul>
                    <li>
                        <asp:Label ID="Label1" runat="server" Text="User Name"></asp:Label>
                        <asp:TextBox ID="txtUser" runat="server"></asp:TextBox></li>
                    <li>
                        <asp:Label ID="Label2" runat="server" Text="Password"></asp:Label>
                        <asp:TextBox ID="txtPwd" runat="server" TextMode="Password"></asp:TextBox></li>
                    <li>
                        <asp:CheckBox ID="cbAutoLogin" runat="server" Text="Auto Login" /></li>
                </ul>
            </div>
        </BodyTemplate>
    </DotNetAge:Dialog>
    <br />
    <br />
    <br />
    <demo:Code runat="server" ID="codeView" SourceFile="~/Dialog/Codes/LoginSample.aspx" />
</asp:Content>
